< previous page page_328 next page >

Page 328
The following source code displays a circle that is first scaled in the X and Y directions and then rotated.
e10a6a0a59f035e870d90cca05b85fce.gif
' Draw the curve on the indicated picture box, 
' scaled and rotated. 
Private Sub DrawCurve(ByVal pic As PictureBox, _ 
    ByVal start_t As Single, ByVal stop_t As Single, _ 
    ByVal dt As Single, _ 
    ByVal x_scale As Single, ByVal y_scale As Single, _ 
    ByVal theta As Single) 
Dim cx As Single 
Dim cy As Single 
Dim sin_theta As Single 
Dim cos_theta As Single 
Dim old_x As Single 
Dim old_y As Single 
Dim new_x As Single 
Dim new_y As Single 
Dim t As Single 

    cx = pic.ScaleLeft + pic.ScaleWidth / 2 
    cy = pic.ScaleTop + pic.ScaleHeight / 2 

    ' Get Cos(theta) and Sin(theta) 
    sin_theta = Sin(theta) 
    cos_theta = Cos(theta) 

    pic.Cls 
    old_x = x_scale * X(start_t) 
    old_y = y_scale * Y(start_t) 
    pic.CurrentX = cx + old_x * cos_theta - old_y * sin_theta 
    pic.CurrentY = cy + old_x * sin_theta + old_y * cos_theta 

    t = start_t + dt 
    Do While t < stop_t 
        old_x = x_scale * X(t) 
        old_y = y_scale * Y(t) 
        pic.Line -( _ 
           cx + old_x * cos_theta - old_y * sin_theta, _ 
           cy + old_x * sin_theta + old_y * cos_theta) 
        t =t + dt 
    Loop 

    old_x = x_scale * X(stop_t) 
    old_y = y_scale * Y(stop_t) 
    pic.Line -( _ 
        cx + old_x * cos_theta - old_y * sin_theta, _
        cy + old_x * sin_theta + old_y * cos_theta) 
End Sub

 
< previous page page_328 next page >